#define DEBUG
#include <cstdio>

using namespace std;

const int maxn=100000, inf=0x7fffffff;

int min(int a, int b) {
  return a<b ? a : b;
}

int max(int a, int b) {
  return a>b ? a : b;
}

class SegmentTree {
public:
  int mv[4*maxn+1], smv[4*maxn+1], mtagv[4*maxn+1], tagv[4*maxn+1], t[4*maxn+1], mtagt[4*maxn+1], tagt[4*maxn+1], mt[4*maxn+1], mtyp[4*maxn+1];

  void merge(int o) {
    if (mv[o*2]==mv[o*2+1]) {
      mv[o] = mv[o*2];
      mtyp[o] = 2;
      smv[o] = min(smv[o*2], smv[o*2+1]);
    } else if (mv[o*2]<mv[o*2+1]) {
      mv[o] = mv[o*2];
      mtyp[o] = 0;
      smv[o] = min(smv[o*2], mv[o*2+1]);
    } else {
      mv[o] = mv[o*2+1];
      mtyp[o] = 1;
      smv[o] = min(smv[o*2+1], mv[o*2]);
    }
  }

  void init(int o, int l, int r, int a[]) {
    if (l==r) {
      mv[o] = a[l];
      smv[o] = inf;
    } else {
      int mid=(l+r)/2;
      init(o*2, l, mid, a), init(o*2+1, mid+1, r, a);
      merge(o);
    }
  }

  void pushDown(int o, int l, int r) {
    mv[o] += mtagv[o], mt[o] += mtagt[o];
    smv[o] += tagv[o];
    if (l!=r) {
      if (smv[o*2]<inf) {
        tagv[o*2] += tagv[o];
        tagt[o*2] += tagt[o];
      }
      if (smv[o*2+1]<inf) {
        tagv[o*2+1] += tagv[o];
        tagt[o*2+1] += tagt[o];
      }
      if (mtyp[o]==0 || mtyp[o]==2) {
        mtagv[o*2] += mtagv[o];
        mtagt[o*2] += mtagt[o];
      } else {
        mtagv[o*2] += tagv[o];
        mtagt[o*2] += tagt[o];
      }
      if (mtyp[o]==1 || mtyp[o]==2) {
        mtagv[o*2+1] += mtagv[o];
        mtagt[o*2+1] += mtagt[o];
      } else {
        mtagv[o*2+1] += tagv[o];
        mtagt[o*2+1] += tagt[o];
      }
    }
    tagv[o] = tagt[o] = mtagv[o] = mtagt[o] = 0;
  }

  void add(int o, int l, int r, int tl, int tr, int tv) {
    pushDown(o, l, r);
    if (l==tl && r==tr) {
      mtagv[o]+=tv, mtagt[o]++;
      if (smv[o]<inf) tagv[o]+=tv, tagt[o]++;
      pushDown(o, l, r);
    } else {
      int mid=(l+r)/2;
      if (tl<=mid) add(o*2, l, mid, tl, min(tr, mid), tv);
      else pushDown(o*2, l, mid);
      if (tr>mid) add(o*2+1, mid+1, r, max(tl, mid+1), tr, tv);
      else pushDown(o*2+1, mid+1, r);
      merge(o);
    }
  }

  void doMax(int o, int l, int r, int tl, int tr, int tv) {
    pushDown(o, l, r);
    int mid=(l+r)/2;
    if (l==r) {
      if (mv[o]<tv) mv[o] = tv, mt[o]++;
    } else if (l==tl && r==tr) {
      if (mv[o]<tv) {
        if (smv[o]>=tv) {
          mtagv[o] += tv-mv[o], mtagt[o]++;
          pushDown(o, l, r);
        } else {
          doMax(o*2, l, mid, l, mid, tv);
          doMax(o*2+1, mid+1, r, mid+1, r, tv);
          merge(o);
        }
      }
    } else {
      if (tl<=mid) doMax(o*2, l, mid, tl, min(tr, mid), tv);
      else pushDown(o*2, l, mid);
      if (tr>mid) doMax(o*2+1, mid+1, r, max(tl, mid+1), tr, tv);
      else pushDown(o*2+1, mid+1, r);
      merge(o);
    }
  }

  int get(int o, int l, int r, int t, int &cnt) {
    pushDown(o, l, r);
    if (l==r) {
      cnt = mt[o];
      return mv[o];
    } else {
      int mid=(l+r)/2;
      if (t<=mid) return get(o*2, l, mid, t, cnt);
      else return get(o*2+1, mid+1, r, t, cnt);
    }
  }
};

int main() {
#ifdef DEBUG
  freopen("src.in", "r", stdin);
  freopen("src.out", "w", stdout);
#endif

  static SegmentTree jsj;
  static int a[maxn+1];
  int n, m;
  scanf("%d", &n);
  for (int i=1; i<=n; i++) scanf("%d", a+i);
  jsj.init(1, 1, n, a);

  scanf("%d", &m);
  for (int i=1; i<=m; i++) {
    char opt;
    int u, v, w;
    scanf(" %c %d", &opt, &u);
    if (opt=='A') {
      scanf("%d %d", &v, &w);
      if (w) jsj.add(1, 1, n, u, v, w);
    } else if (opt=='M') {
      scanf("%d %d", &v, &w);
      jsj.doMax(1, 1, n, u, v, w);
    } else {
      int cnt, val=jsj.get(1, 1, n, u, cnt);
      printf("%d %d\n", val, cnt);
    }
  }

  fclose(stdin);
  fclose(stdout);
  return 0;
}
